package com.cyl.h5.controller;


import com.cyl.manager.act.domain.entity.FhMyai;
import com.cyl.manager.act.domain.query.FhMyaiQuery;
import com.cyl.manager.act.service.FhMyaiService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(description ="ai管理接口列表")
@RestController
@RequestMapping("/app/fhMyai")
public class H5FhMyaiController extends BaseController {
    @Autowired
    private FhMyaiService service;

    @ApiOperation("查询ai管理列表")
    @PostMapping("/list")
    public ResponseEntity<Page<FhMyai>> list(@RequestBody FhMyaiQuery query, Pageable page) {
        List<FhMyai> list = service.selectList(query, page);
        return ResponseEntity.ok(new PageImpl<>(list, page, ((com.github.pagehelper.Page)list).getTotal()));
    }


    @ApiOperation("获取ai管理详细信息")
    @GetMapping(value = "/{id}")
    public ResponseEntity<FhMyai> getInfo(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(service.selectById(id));
    }

    @ApiOperation("新增ai管理")
    @Log(title = "ai管理", businessType = BusinessType.INSERT)
    @PostMapping
    public ResponseEntity<Integer> add(@RequestBody FhMyai fhMyai) {
        return ResponseEntity.ok(service.insert(fhMyai));
    }

    @ApiOperation("修改ai管理")
    @Log(title = "ai管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResponseEntity<Integer> edit(@RequestBody FhMyai fhMyai) {
        return ResponseEntity.ok(service.update(fhMyai));
    }

    @ApiOperation("删除ai管理")
    @Log(title = "ai管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public ResponseEntity<Integer> remove(@PathVariable Long[] ids) {
        return ResponseEntity.ok(service.deleteByIds(ids));
    }
}
